<template>
	<div class="middle">
		<el-row>
			<el-col>
				<label><i class="el-icon-caret-right"></i>就诊卡号:</label>
				<el-input class="triage" v-model="patient.cardId" style="width:100px;" @keyup.enter.native="handleSwing"></el-input>

				<label><i class="el-icon-caret-right"></i>患者姓名:</label>
				<el-input @change="checkName" :class="isRepeat?'triage danger':'triage'" v-model="patient.name" style="width:100px;" :title="isRepeat?'可能是24小时内再次就诊患者，请留意病情变化':''"></el-input>

				<label><i class="el-icon-caret-right"></i>性别:</label>
				<el-select class="triage" placeholder="" v-model="patient.sex" style="width:50px;">
					<el-option
						v-for="item in sexList"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>

				<label><i class="el-icon-caret-right"></i>年龄:</label>
				<el-input class="triage" v-model="patient.age" style="width:40px;"></el-input>岁

				<label><i class="el-icon-caret-right"></i>电话:</label>
				<el-input class="triage" v-model="patient.telphone" style="width:120px;"></el-input>

				<label><i class="el-icon-caret-right"></i>地址:</label>
				<el-input class="triage" v-model="patient.address" style="width:200px;"></el-input>

				<light style="float:right"></light>
			</el-col>
			<el-col>
				<label><i class="el-icon-caret-right"></i>神志:</label>
				<el-select class="triage" placeholder="" v-model="patient.sense" @change="getLifeLight" style="width:115px;" clearable>
					<el-option
						v-for="item in senseList"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>

				<label><i class="el-icon-caret-right"></i>体温:</label>
				<el-input class="triage" v-model="patient.temperature" v-on:blur="getLifeLight" style="width:45px;"></el-input>°C

				<label><i class="el-icon-caret-right"></i>脉搏:</label>
				<el-input class="triage" v-model="patient.pulseRate" v-on:blur="getLifeLight" style="width:45px;"></el-input>次/分
				<label><i class="el-icon-caret-right"></i>脉搏节律:</label>
				<el-select class="triage" placeholder="" v-model="patient.pulseRhythm" @change="getLifeLight" style="width:95px;" clearable>
					<el-option
						v-for="item in pulseList"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>

				<label><i class="el-icon-caret-right"></i>呼吸:</label>
				<el-input class="triage" v-model="patient.breathRate" v-on:blur="getLifeLight"  style="width:45px;"></el-input>次/分

				<label><i class="el-icon-caret-right"></i>呼吸节律:</label>
				<el-select class="triage" placeholder="" v-model="patient.breathRhythm" @change="getLifeLight" style="width:85px;" clearable>
					<el-option
						v-for="item in breathList"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>

				<label><i class="el-icon-caret-right"></i>血压:</label>
				<el-input class="triage" v-model="patient.sbp" v-on:blur="getLifeLight" style="width:40px;"></el-input>
				<label>/</label>
				<el-input class="triage" v-model="patient.dbp" v-on:blur="getLifeLight" style="width:40px;"></el-input>mmHg

				<label><i class="el-icon-caret-right"></i></label>
				<el-checkbox  v-model="patient.is120">120</el-checkbox>
				<label><i class="el-icon-caret-right"></i></label>
				<el-checkbox  v-model="patient.isGreen">绿色通道</el-checkbox>
			</el-col>
			<el-col :span="23">
				<label><i class="el-icon-caret-right"></i>发病时间:</label>
				<!-- <el-input class="triage" style="width:40px;" @change="getLifeLight" v-model="patient.timeNumber"></el-input>
				<el-select class="triage" placeholder="" @change="getLifeLight" v-model="patient.timeUnit" style="width:70px;" clearable>
					<el-option
						v-for="item in unitList"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select> -->

				<el-autocomplete @select="getLifeLight" @change.native="getLifeLight" class="triage" 
					v-model="patient.diseaseTime"
					:fetch-suggestions="queryDiseaseTime"
					style="width:70px;">
				</el-autocomplete>

				<label><i class="el-icon-caret-right"></i>处置地点:</label>
				<el-select class="triage" placeholder="" @change="setTriageTime" v-model="patient.handlePlace" style="width:120px;" clearable>
					<el-option
						v-for="item in placeList"
						:key="item.value"
						:label="item.handlePlace"
						:value="item.handlePlace">
					</el-option>
				</el-select>

				<label><i class="el-icon-caret-right"></i>过敏史:</label>
				<el-select class="triage" placeholder="" v-model="patient.allergy" multiple collapse-tags style="width:200px;">
					<el-option
						v-for="item in allergyList"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>

				<label><i class="el-icon-caret-right"></i>送入科室:</label>
				<el-select class="triage" @change="setDepartTime" placeholder="" v-model="patient.department" style="width:150px;" clearable>
					<el-option
						v-for="item in departmentList"
						:key="item.deptId"
						:label="item.deptName"
						:value="item.deptName">
					</el-option>
				</el-select>

				<label><i class="el-icon-caret-right"></i>处置结果:</label>
				<el-select class="triage" placeholder="" v-model="patient.handleResult" style="width:70px;" clearable>
					<el-option
						v-for="item in resultList"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>

				<label><i class="el-icon-caret-right"></i>处置时间:</label>
				<el-select class="triage" placeholder="" v-model="patient.handleTime" style="width:90px;" clearable>
					<el-option
						v-for="item in timeList"
						:key="item.value"
						:label="item.label"
						:value="item.value">
					</el-option>
				</el-select>

			</el-col>
		</el-row>
	</div>
</template>
<script type="text/javascript">
	import Light from '@/components/Light'
	export default{
		name:"Middle",
		components:{Light},
		data(){
			return {
				curUser:{},
				isRepeat:false,
				sexList:[{
					value:"男",
					label:"男"
				},{
					value:"女",
					label:"女"
				}],
				senseList:[{
					value:"意识清楚",
					label:"意识清楚",
					light: "1",
					code: "a1"
				},{
					value:"意识模糊",
					label:"意识模糊",
					light: "3",
					code: "a3"
				},{
					value:"躁动谵妄",
					label:"躁动谵妄",
					light: "3",
					code: "a5"
				},{
					value:"昏睡",
					label:"昏睡",
					light: "3",
					code: "a4"
				},{
					value:"昏迷",
					label:"昏迷",
					light: "4",
					code: "a7"
				},{
					value:"抽搐",
					label:"抽搐",
					light: "4",
					code: "a6"
				},{
					value:"晕厥",
					label:"晕厥",
					light: "3",
					code: "a8"

				},{
					value:"突发意识丧失",
					label:"突发意识丧失",
					light: "4",
					code: "a9"
				}],
				pulseList:[{
					value:"整齐",
					label:"整齐",
					light: "1",
					code: "g1"
				},{
					value:"不齐<5次",
					label:"不齐<5次",
					light: "2",
					code: "g2"
				},{
					value:"不齐≥5次",
					label:"不齐≥5次",
					light: "2",
					code: "g3"
				},{
					value:"不齐呈联律",
					label:"不齐呈联律",
					light: "4",
					code: "g4"
				},{
					value:"停顿>3秒",
					label:"停顿>3秒",
					light: "4",
					code: "g5"
				},{
					value:"绝对不齐≤100次",
					label:"绝对不齐≤100次",
					light: "2",
					code: "g6"
				},{
					value:"绝对不齐101-109次",
					label:"绝对不齐101-109次",
					light: "2",
					code: "g10"
				},{
					value:"绝对不齐110-130次",
					label:"绝对不齐110-130次",
					light: "3",
					code: "g7"
				},{
					value:"绝对不齐>130次",
					label:"绝对不齐>130次",
					light: "4",
					code: "g8"
				},{
					value:"快慢交替",
					label:"快慢交替",
					light: "3",
					code: "g9"
				}],
				breathList:[{
					value:"正常",
					label:"正常",
					light: "1",
					code: "f1"
				},{
					value:"呼吸浅快",
					label:"呼吸浅快",
					light: "3",
					code: "f2"
				},{
					value:"呼吸浅慢",
					label:"呼吸浅慢",
					light: "4",
					code: "f3"
				},{
					value:"潮式呼吸",
					label:"潮式呼吸",
					light: "4",
					code: "f4"
				},{
					value:"间停呼吸",
					label:"间停呼吸",
					light: "4",
					code: "f5"
				}],
				allergyList:[{
					value:"青霉素",
					label:"青霉素"
				},{
					value:"链霉素",
					label:"链霉素"
				},{
					value:"头孢菌素",
					label:"头孢菌素"
				},{
					value:"破伤风抗毒素",
					label:"破伤风抗毒素"
				},{
					value:"盐酸普鲁卡因",
					label:"盐酸普鲁卡因"
				},{
					value:"磺胺类",
					label:"磺胺类"
				},{
					value:"喹诺酮类",
					label:"喹诺酮类"
				}],
				unitList:[{
					value:"分钟",
					label:"分钟"
				},{
					value:"小时",
					label:"小时"
				},{
					value:"天",
					label:"天"
				},{
					value:"周",
					label:"周"
				},{
					value:"月",
					label:"月"
				}],
				placeList:[],
				timeList:[{
					value:"即刻",
					label:"即刻"
				},{
					value:"2分钟",
					label:"2分钟"
				},{
					value:"4分钟",
					label:"4分钟"
				},{
					value:"6分钟",
					label:"6分钟"
				},{
					value:"8分钟",
					label:"8分钟"
				},{
					value:"10分钟",
					label:"10分钟"
				},{
					value:"15分钟",
					label:"15分钟"
				},{
					value:"30分钟",
					label:"30分钟"
				},{
					value:"1小时",
					label:"1小时"
				},{
					value:"2小时",
					label:"2小时"
				}],
				resultList:[{
					value:"成功",
					label:"成功"
				},{
					value:"失败",
					label:"失败"
				}],
				departmentList:[]
			}
		},
		computed:{
			light(){
				return this.$store.state.light;
			},
			lifeCodes:{
				set(value){
				},
				get(){
					return this.$store.state.lifeCodes;
				}
			},
			patient:{
				set(value){
				},
				get(){
					return this.$store.state.patient;
				}
			},
			showCard:{
				set(value){
				},
				get(){
					return this.$store.state.showCard;
				}
			},
			reData:{
				set(value){
				},
				get(){
					return this.$store.state.reData;
				}
			},
		},
		methods:{
			getLifeLight:function(){
				var lifeLight = "";
				var lifeCodes = "";
				var tDiseaseCode = "";
				var vm = this;
				//神志判断
				if (vm.patient.sense) {
					var curVal =vm.patient.sense;
					vm.senseList.forEach(function(sense){
						if (curVal == sense.value) {
							lifeLight = lifeLight + sense.light;
							lifeCodes = lifeCodes +sense.code+",";
						}
					});
				}

				//体温判断
				if (vm.patient.temperature) {
					var curVal = vm.patient.temperature;
					if (curVal>=36 && curVal<=37.2) {
						lifeLight = lifeLight + "1";
						lifeCodes = lifeCodes +"b1,";
					}else if (curVal>=37.3 && curVal<38) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes +"b2,";
					}else if (curVal>=38 && curVal<=39) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes +"b3,";
					}else if (curVal>=39.1 && curVal<=41) {
						lifeLight = lifeLight + "3";
						lifeCodes = lifeCodes +"b4,";
					}else if (curVal>=35.5 && curVal<=35.9) {
						lifeLight = lifeLight + "3";
						lifeCodes = lifeCodes +"b5,";
					}else if (curVal>41) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"b6,";
					}else if (curVal<35.5) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"b7,";
					}
					//判断体温对应的处置编号，最终替换T
					if (curVal<36) {
						tDiseaseCode = "100.1";
					}else if (curVal>=37.3&&curVal<38) {
						tDiseaseCode = "100.2";
					}else if (vm.patient.age) {
						var age = vm.patient.age;
						if (age<60&&age>14&&curVal<=39&&curVal>=38) {
							tDiseaseCode = "100.3";
						}else if (age<60&&age>14&&curVal>=39&&curVal<=41) {
							tDiseaseCode = "100.4";
						}else if (age<60&&age>14&&curVal>41) {
							tDiseaseCode = "100.5";
						}else if (age>60&&curVal<=39&&curVal>=38.1) {
							tDiseaseCode = "100.6";
						}else if (age>60&&curVal>=39&&curVal<=41) {
							tDiseaseCode = "100.7";
						}else if (age>60&&curVal>41) {
							tDiseaseCode = "100.8";
						}else if (age<=14&&curVal<=39&&curVal>=38.1) {
							tDiseaseCode = "100.9";
						}else if (age<=14&&curVal>=39&&curVal<=41) {
							tDiseaseCode = "100.10";
						}else if (age<=14&&curVal>41) {
							tDiseaseCode = "100.11";
						}
					}else {
						age = 28;//如果没输入年龄，默认成人，后期更改
						if (age<60&&age>14&&curVal<=39&&curVal>=38) {
							tDiseaseCode = "100.3";
						}else if (age<60&&age>14&&curVal>=39&&curVal<=41) {
							tDiseaseCode = "100.4";
						}else if (age<60&&age>14&&curVal>41) {
							tDiseaseCode = "100.5";
						}else if (age>60&&curVal<=39&&curVal>=38.1) {
							tDiseaseCode = "100.6";
						}else if (age>60&&curVal>=39&&curVal<=41) {
							tDiseaseCode = "100.7";
						}else if (age>60&&curVal>41) {
							tDiseaseCode = "100.8";
						}else if (age<=14&&curVal<=39&&curVal>=38.1) {
							tDiseaseCode = "100.9";
						}else if (age<=14&&curVal>=39&&curVal<=41) {
							tDiseaseCode = "100.10";
						}else if (age<=14&&curVal>41) {
							tDiseaseCode = "100.11";
						}
					}
				}

				//脉搏判断
				if (vm.patient.pulseRate) {
					var curVal = vm.patient.pulseRate;
					if (curVal>=60 && curVal<=100) {
						lifeLight = lifeLight + "1";
						lifeCodes = lifeCodes +"c1,";
					}else if (curVal>=50 && curVal<=59) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes +"c2,";
					}else if (curVal>=101 && curVal<=109) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes +"c3,";
					}else if (curVal>=110 && curVal<=130) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes +"c4,";
					}else if (curVal>=131 && curVal<=150) {
						lifeLight = lifeLight + "3";
						lifeCodes = lifeCodes +"c5,";
					}else if (curVal>=40 && curVal<=49) {
						lifeLight = lifeLight + "3";
						lifeCodes = lifeCodes +"c6,";
					}else if (curVal>=151) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"c7,";
					}else if (curVal<35 && curVal>0) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"c8,";
					}else if (curVal==0) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"c9,";
					}else if (curVal>=35 && curVal<=39) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"c10,";
					}
				}
				//年龄判断，年龄不单独触发诊断
				if (vm.patient.age) {
					var curVal =vm.patient.age;
					if (curVal<40) {
						lifeCodes = lifeCodes +"w1,";
					}else if(curVal>39){
						lifeCodes = lifeCodes +"w2,";
					}
				}else{
					lifeCodes = lifeCodes +"w2,";
				}

				//脉搏节律判断
				if (vm.patient.pulseRhythm) {
					var curVal =vm.patient.pulseRhythm;
					vm.pulseList.forEach(function(pulse){
						if (curVal == pulse.value) {
							lifeLight = lifeLight + pulse.light;
							lifeCodes = lifeCodes + pulse.code +",";
						}
					});
				}

				//呼吸判断
				if (vm.patient.breathRate) {
					var curVal = vm.patient.breathRate;
					if (curVal>=12 && curVal<=20) {
						lifeLight = lifeLight + "1";
						lifeCodes = lifeCodes +"d1,";
					}else if (curVal>=21 && curVal<=25) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes +"d2,";
					}else if (curVal>=10 && curVal<=12) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes +"d3,";
					}else if (curVal>=26 && curVal<=30) {
						lifeLight = lifeLight + "3";
						lifeCodes = lifeCodes +"d4,";
					}else if (curVal>=8 && curVal<=10) {
						lifeLight = lifeLight + "3";
						lifeCodes = lifeCodes +"d5,";
					}else if (curVal>=31 && curVal<=35) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"d6,";
					}else if (curVal>=5 && curVal<=7) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"d7,";
					}else if (curVal>=36) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"d8,";
					}else if (curVal<5 && curVal>0) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"d9,";
					}else if (curVal==0) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes +"d10,";
					}
				}

				//呼吸节律判断
				if (vm.patient.breathRhythm) {
					var curVal =vm.patient.breathRhythm;
					vm.breathList.forEach(function(breath){
						if (curVal == breath.value) {
							lifeLight = lifeLight + breath.light;
							lifeCodes = lifeCodes + breath.code +",";
						}
					});
				}

				//血压判断
				if (vm.patient.sbp && vm.patient.dbp) {
					var sbp = vm.patient.sbp;
					var dbp = vm.patient.dbp;
					if ((sbp>=90 && sbp<=140) && (dbp>=60 && dbp<=90)){
						lifeLight = lifeLight + "1";
						lifeCodes = lifeCodes + "e1,";
					}else if (sbp>140 && dbp<90) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes + "e2,";
					}else if ((sbp>=141 && sbp<=150) && dbp>90) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes + "e3,";
					}else if ((sbp>=151 && sbp<=160) && dbp>90) {
						lifeLight = lifeLight + "2";
						lifeCodes = lifeCodes + "e4,";
					}else if ((sbp>=160 && sbp<180) && dbp>=90) {
						lifeLight = lifeLight + "3";
						lifeCodes = lifeCodes + "e5,";
					}else if (sbp>=180 && dbp>=100) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes + "e6,";
					}else if ((sbp>=81 && sbp<=89) && dbp<=60) {
						lifeLight = lifeLight + "3";
						lifeCodes = lifeCodes + "e7,";
					}else if (sbp<=80 && sbp>0 && dbp<=60 && dbp>0) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes + "e8,";
					}else if ((sbp>=90 && sbp<=120) && (sbp-dbp)<10) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes + "e9,";
					}else if (sbp==0 && dbp==0) {
						lifeLight = lifeLight + "4";
						lifeCodes = lifeCodes + "e10,";
					}
				}
				//发病时间判断
				if (vm.patient.diseaseTime) {
					if (vm.patient.diseaseTime.indexOf("分钟")>0) {
						let timeNumber = vm.patient.diseaseTime.replace("分钟","");
						if (timeNumber<=180) {
							lifeCodes = lifeCodes + "t1,";
						}else if (timeNumber<=720) {
							lifeCodes = lifeCodes + "t2,";
						}else if (timeNumber<=2160) {
							lifeCodes = lifeCodes + "t3,";
						}else{
							lifeCodes = lifeCodes + "t4,";
						}
					}else if (vm.patient.diseaseTime.indexOf("小时")>0) {
						let timeNumber = vm.patient.diseaseTime.replace("小时","");
						if (timeNumber<=3) {
							lifeCodes = lifeCodes + "t1,";
						}else if (timeNumber<=12) {
							lifeCodes = lifeCodes + "t2,";
						}else if (timeNumber<=36) {
							lifeCodes = lifeCodes + "t3,";
						}else{
							lifeCodes = lifeCodes + "t4,";
						}
					}else if (vm.patient.diseaseTime.indexOf("天")>0) {
						lifeCodes = lifeCodes + "t4,";
					}else if (vm.patient.diseaseTime.indexOf("周")>0) {
						lifeCodes = lifeCodes + "t4,";
					}else if (vm.patient.diseaseTime.indexOf("月")>0) {
						lifeCodes = lifeCodes + "t4,";
					}
				}
				vm.patient.lifeCodes = lifeCodes;
				//存在监控对象属性问题，新增一个临时解决
				vm.$store.commit({
						type:"setLifeCodes",
						lifeCodes:lifeCodes
					});
				vm.patient.tDiseaseCode = tDiseaseCode;
				vm.$store.commit({
						type:"setLight",
						light:{
							curLight: vm.light.curLight,
							manualLight: vm.light.manualLight,
							diseaseLight:vm.light.diseaseLight,
							lifeLight:lifeLight
						}
					});
				this.getNursePlan();
				//计算MEWS评分
				if (vm.patient.pulseRate&&vm.patient.sbp&&vm.patient.breathRate&&vm.patient.temperature&&vm.patient.sense) {
		    		let mews = 0;
		    		//心率MEWS
		    		if (vm.patient.pulseRate==0||vm.patient.pulseRate>130) {
		    			mews = mews + 3;
		    		}else if (vm.patient.pulseRate<41||vm.patient.pulseRate>110&&vm.patient.pulseRate<131) {
		    			mews = mews + 2;
		    		}else if (vm.patient.pulseRate>40&&vm.patient.pulseRate<51||vm.patient.pulseRate>100&&vm.patient.pulseRate<=111) {
		    			mews = mews + 1;
		    		}

		    		//收缩压MEWS
		    		if (vm.patient.sbp<71) {
		    			mews = mews + 3;
		    		}else if (vm.patient.sbp>70&&vm.patient.sbp<81) {
		    			mews = mews + 2;
		    		}else if (vm.patient.sbp>80&&vm.patient.sbp<101) {
		    			mews = mews + 1;
		    		}

		    		//呼吸频率MEWS
		    		if (vm.patient.breathRate==0||vm.patient.breathRate>29) {
		    			mews = mews + 3;
		    		}else if (vm.patient.breathRate<10||vm.patient.breathRate>20&&vm.patient.breathRate<30) {
		    			mews = mews + 2;
		    		}else if (vm.patient.breathRate>14&&vm.patient.breathRate<21) {
		    			mews = mews + 1;
		    		}

		    		//体温MEWS
		    		if (vm.patient.temperature<=35||vm.patient.temperature>=38.5) {
		    			mews = mews + 2;
		    		}

		    		//神志MEWS
		    		if (vm.patient.sense == "躁动谵妄") {
		    			mews = mews + 1;
		    		}else if (vm.patient.sense == "意识模糊"||vm.patient.sense == "昏睡") {
		    			mews = mews + 2;
		    		}else if (vm.patient.sense == "昏迷"||vm.patient.sense == "抽搐"||vm.patient.sense == "晕厥"||vm.patient.sense == "突发意识丧失") {
		    			mews = mews + 3;
		    		}
		    		vm.patient.mews =  mews;
		    	}else{
		    		vm.patient.mews =  "-1";
		    	}
			},
			getNursePlan:function(){
				//this.showCard.name = "nurse";
				var vm = this;
				vm.patient.nurseDisposals = [];
				vm.$axios.getNurseDisposal(vm.patient.lifeCodes).then(function(res){
					if (res.data&&res.data.data) {
						vm.patient.nurseDisposals = res.data.data;
					}
				},function(res){
					console.log("error:"+res);
				});
			},
			checkName:function(){
				var vm =this;
				vm.$axios.getRepeatCount(vm.patient.name).then(function(res){
					vm.isRepeat = false;
					if (res&&res.data&&res.data.data>0) {
						vm.isRepeat = true;
					}
				},function(res){
					console.log("error"+res);
				});
			},
			handleSwing:function(){
				var vm =this;
				vm.$axios.swingCard(vm.patient.cardId,vm.curUser.hospitalCode).then(function(res){
					if (res&&res.data&&res.data.data) {
						var record = res.data.data;
						if (record.recordUUID) {
		    				vm.$set(vm.patient,'patientUUID',record.recordUUID);
		    				vm.$set(vm.patient,'nodeUUID',record.nodeUUID);
		    				vm.$set(vm.patient,"name",record.recordName);
		    				vm.$set(vm.patient,"sex",record.recordSex);
		    				vm.$set(vm.patient,"cardId",record.recordCard);
		    				vm.$set(vm.patient,"hospitalCode",record.hospitalCode);
		    				vm.$set(vm.patient,"age",record.recordAge);
		    				vm.$set(vm.patient,"recordTel",record.telphone);
		    				vm.$set(vm.patient,"address",record.recordAddress);
		    				vm.$set(vm.patient,"sense",record.recordSense);
		    				vm.$set(vm.patient,"temperature",record.recordTemperature);
		    				vm.$set(vm.patient,"pulseRhythm",record.recordPulseRhythm);
		    				vm.$set(vm.patient,"pulseRate",record.recordPulseRate);
		    				vm.$set(vm.patient,"breathRate",record.recordBreathRate);
		    				vm.$set(vm.patient,"breathRhythm",record.recordBreathRhythm);
		    				vm.$set(vm.patient,"sbp",record.recordSBP);
		    				vm.$set(vm.patient,"dbp",record.recordDBP);
		    				vm.$set(vm.patient,"allergy",record.recordAllergy==""?[]:record.recordAllergy.split(","));
		    				vm.$set(vm.patient,"diseaseTime",record.recordDiseaseTime);
		    				vm.$set(vm.patient,"departTime",record.departTime);
		    				vm.$set(vm.light,"curLight",record.recordLight);
		    				vm.$set(vm.light,"manualLight",record.recordManualLight);
		    				vm.$set(vm.patient,"is120",record.is120=="true"?true:false);
		    				vm.$set(vm.patient,"isGreen",record.isGreen=="true"?true:false);
		    				vm.$set(vm.patient,"handlePlace",record.handlePlace);
		    				vm.$set(vm.patient,"handleTime",record.handleTime);
		    				vm.$set(vm.patient,"triageTime",record.triageTime);
		    				vm.$set(vm.patient,"nurse",record.nurse);
		    				vm.$set(vm.patient,"doctor",record.doctor);
		    				vm.$set(vm.patient,"department",record.sendDept);
		    				vm.$set(vm.patient,"result",record.handleResult);
		    				vm.$set(vm.patient,"complaintCode",record.complaintCode);
		    				vm.$set(vm.patient,"complaintName",record.complaintName);
		    				vm.$set(vm.patient,"nurseSymptom",record.nurseSymptom);
		    				vm.$set(vm.patient,"nurseDisease",record.nurseDisease);
		    				vm.$set(vm.patient,"mews",record.mews);
		    				vm.$set(vm.patient,"startTime",record.startTime);

				    		vm.reData.patient = record;
						}else{
							vm.$set(vm.patient,"name",record.name);
		    				vm.$set(vm.patient,"sex",record.sex);
		    				vm.$set(vm.patient,"age",record.age);
						}
						//患者名字检查，判断是不是近期看过病
						vm.checkName();
					}
				});
			},
			setTriageTime:function(){
				if (this.patient.handlePlace == "") {
					this.patient.triageTime = '';
				}else{
					this.patient.triageTime = this.commonUtil.dateFormat(new Date(),'yyyy-MM-dd hh:mm:ss');
				}
			},
			setDepartTime:function(){
				if (this.patient.department == "") {
					this.patient.departTime = '';
				}else{
					this.patient.departTime = this.commonUtil.dateFormat(new Date(),'yyyy-MM-dd hh:mm:ss');
				}
			},
			queryDiseaseTime:function(queryString, cb){
				var result = [];
				if (!isNaN(queryString)&&queryString) {
					var units = ['分钟','小时','天','周','个月'];
					units.forEach(function(unit){
						result.push({
							value:queryString+unit
						});
					});
				}
				cb(result);
			}
		},
		mounted(){
			  //初始化科室信息
			  var vm = this;
			  vm.curUser = this.$cookies.get("curUser");
		      this.$axios.queryDepts(vm.curUser.hospitalCode).then(function(res){
		        vm.departmentList = [];
		        if (res.data&&res.data.data) {
		        	vm.departmentList = res.data.data;
		        }
		      },function(res){
		          console.log("error"+res);
		      });
		      //初始化处置地点信息
		      vm.$axios.queryAllPlace(vm.curUser.hospitalCode).then(function(res){
		        vm.placeList = [];
		        if (res.data&&res.data.data) {
		        	vm.placeList = res.data.data;
		        }
		      },function(res){
		          console.log("error"+res);
		      });
		},
		watch:{
			patient:{
				handler(curVal,oldVal){
					if (!this.patient.startTime) {
						this.$set(this.patient,"startTime",this.commonUtil.dateFormat(new Date(),'yyyy-MM-dd hh:mm:ss'));
					}
					this.$store.commit({
						type:"setPatient",
						patient:curVal
					});
				},
				deep:true
			},
			reData:{
				handler(curVal,oldVal){
					this.getLifeLight();
				},
				deep:true
			},
		}
	}
</script>
<style type="text/css" scoped>
	.middle{
		text-align: left;
		padding-left: 5px;
	}
	.el-col{
		margin-top: 10px;
	}
	label{
		color: #708090;
	}
</style>